Put window exporting behind a display protocol agnostic API
authorMatthias Clasen <mclasen@redhat.com>
Tue, 26 Jul 2016 19:46:41 +0000 (15:46 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 28 Jul 2016 17:01:22 +0000 (13:01 -0400)
Introduce a private API meant for abstracting how to get a handle
of a window that can be shared with other processes. The API is
async, since some implementations will require that. Currently,
only X11 is supported, which doesn't.

Based on a patch by Jonas Adahl.

gtk/gtkwindow.c
gtk/gtkwindowprivate.h

index 9146a03b14e20d798ad4aad971a1f4b3014d1f51..943561ef4ae753b5ea7edfb5f17c6349f8330206 100644 (file)
@@ -12612,3 +12612,33 @@ gtk_window_set_hardcoded_window (GtkWindow *window,
 
   g_set_object (&priv->hardcoded_window, gdk_window);
 }
+
+gboolean
+gtk_window_export_handle (GtkWindow               *window,
+                          GtkWindowHandleExported  callback,
+                          gpointer                 user_data)
+{
+  GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
+    {
+      char *handle_str;
+      guint32 xid = (guint32) gdk_x11_window_get_xid (gdk_window);
+
+      handle_str = g_strdup_printf ("x11:%x", xid);
+      callback (window, handle_str, user_data);
+
+      return TRUE;
+    }
+#endif
+
+  g_warning ("Couldn't export handle, unsupported windowing system");
+
+  return FALSE;
+}
+
+void
+gtk_window_unexport_handle (GtkWindow *window)
+{
+}
index 80253bf55cfe3cc4bb95a06b9e484623ff31fee6..5cb5a72db231125d96096bcb702fa17caf0ac0cd 100644 (file)
@@ -135,6 +135,17 @@ void       gtk_window_set_hardcoded_window (GtkWindow *window,
 
 GdkScreen *_gtk_window_get_screen (GtkWindow *window);
 
+/* Exported handles */
+
+typedef void (*GtkWindowHandleExported)  (GtkWindow               *window,
+                                          const char              *handle,
+                                          gpointer                 user_data);
+
+gboolean      gtk_window_export_handle   (GtkWindow               *window,
+                                          GtkWindowHandleExported  callback,
+                                          gpointer                 user_data);
+void          gtk_window_unexport_handle (GtkWindow               *window);
+
 G_END_DECLS
 
 #endif /* __GTK_WINDOW_PRIVATE_H__ */